﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>新增供应商信息</title>
    <link href="~/libs/layui-v2.9.17/layui/css/layui.css" rel="stylesheet" />
    <script src="~/libs/layui-v2.9.17/layui/layui.js"></script>
    <script src="~/libs/jquery/jquery.js"></script>
</head>
<body>
    <form class="layui-form" action="" onsubmit="return false">
        <div class="layui-form-item">
            <label class="layui-form-label">供应商编码</label>
            <div class="layui-input-block">
                <input type="text" id="vendorCode" name="vendorCode" lay-verify="required" placeholder="请输入供应商编码" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">供应商名称</label>
            <div class="layui-input-block">
                <input type="text" id="vendorName" name="vendorName" lay-verify="required" placeholder="请输入供应商名称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">供应商简写</label>
            <div class="layui-input-block">
                <input type="text" id="vendorNick" name="vendorNick" lay-verify="required" placeholder="请输入供应商简写" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">供应商英文名称</label>
            <div class="layui-input-block">
                <input type="text" id="vendorEn" name="vendorEn" lay-verify="required" placeholder="请输入供应商英文名称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">供应商简介</label>
            <div class="layui-input-block">
                <textarea placeholder="请输入供应商简介" class="layui-textarea" id="vendorDesc" name="vendorDesc"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">供应商LOGO地址</label>
            <div class="layui-input-block">
                <input type="text" id="vendorLogo" name="vendorLogo" lay-verify="required" placeholder="请输入供应商LOGO地址" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">供应商等级</label>
            <div class="layui-input-block">
                <input type="text" id="vendorLevel" name="vendorLevel" lay-verify="required" placeholder="请输入供应商等级" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">供应商评分</label>
            <div class="layui-input-block">
                <input type="text" id="vendorScore" name="vendorScore" lay-verify="required" placeholder="请输入供应商评分" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">供应商地点</label>
            <div class="layui-input-block">
                <input type="text" id="address" name="address" lay-verify="required" placeholder="请输入供应商地点" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">供应商官网地址</label>
            <div class="layui-input-block">
                <input type="text" id="webSite" name="webSite" lay-verify="required" placeholder="请输入供应商官网地址" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">供应商邮箱</label>
            <div class="layui-input-block">
                <input type="text" id="email" name="email" lay-verify="required" placeholder="请输入供应商邮箱" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">供应商电话</label>
            <div class="layui-input-block">
                <input type="text" id="tel" name="tel" lay-verify="required" placeholder="请输入供应商电话" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">联系人姓名1</label>
            <div class="layui-input-block">
                <input type="text" id="contact1" name="contact1" lay-verify="required" placeholder="请输入联系人1" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">联系人1电话</label>
            <div class="layui-input-block">
                <input type="text" id="contact1Tel" name="contact1Tel" lay-verify="required" placeholder="请输入联系人1电话" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">联系人1邮箱</label>
            <div class="layui-input-block">
                <input type="text" id="contact1Email" name="contact1Email" lay-verify="required" placeholder="请输入联系人1邮箱" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">统一社会信用代码</label>
            <div class="layui-input-block">
                <input type="text" id="creditCode" name="creditCode" lay-verify="required" placeholder="请输入统一社会信用代码" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea placeholder="请输入备注内容" class="layui-textarea" id="remark" name="remark"></textarea>
            </div>
        </div>
        <input type="hidden" name="id" id="id">
        @* <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn" lay-submit lay-filter="demo1">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div> *@
    </form>
    <script type="text/javascript">
        layui.use('form', function () {
            const form = layui.form;
            form.render();
            var id = window.location.search.substring(4);
            $.ajax({
                url: '/ChuBoWen/GetMdVendorBuBy?id=' + id,
                type: 'get',
                data: $('#form').serialize(),
                success: function (res) {
                    console.log(res);
                    $("#id").val(res.id)
                    $("#vendorCode").val(res.vendorCode)
                    $("#vendorName").val(res.vendorName)
                    $("#vendorNick").val(res.vendorNick)
                    $("#vendorEn").val(res.vendorEn)
                    $("#vendorDesc").val(res.vendorDesc)
                    $("#vendorLogo").val(res.vendorLogo)
                    $("#vendorLevel").val(res.vendorLevel)
                    $("#vendorScore").val(res.vendorScore)
                    $("#address").val(res.address)
                    $("#webSite").val(res.webSite)
                    $("#email").val(res.email)
                    $("#tel").val(res.tel)
                    $("#contact1").val(res.contact1)
                    $("#contact1Tel").val(res.contact1Tel)
                    $("#contact1Email").val(res.contact1Email)
                    $("#creditCode").val(res.creditCode)
                    $("#remark").val(res.remark)
                }
            });
        })

        // layui.use(['form', 'jquery', 'layer'], function () {
        //     const form = layui.form;
        //     var $ = layui.jquery;
        //     var layer = layui.layer;
        //     form.render();
        //     var id = window.location.search.substring(4);
        //     console.log(id);
        //     $.ajax({
        //         url: '/ChuBoWen/GetMdVendorBuBy?id=' + id,
        //         type: 'get',
        //         data: $('#form').serialize(),
        //         success: function (res) {
        //             console.log(res);
        //             $("#id").val(res.id)
        //             $("#vendorCode").val(res.vendorCode)
        //             $("#vendorName").val(res.vendorName)
        //             $("#vendorNick").val(res.vendorNick)
        //             $("#vendorEn").val(res.vendorEn)
        //             $("#vendorDesc").val(res.vendorDesc)
        //             $("#vendorLogo").val(res.vendorLogo)
        //             $("#vendorLevel").val(res.vendorLevel)
        //             $("#vendorScore").val(res.vendorScore)
        //             $("#address").val(res.address)
        //             $("#webSite").val(res.webSite)
        //             $("#email").val(res.email)
        //             $("#tel").val(res.tel)
        //             $("#contact1").val(res.contact1)
        //             $("#contact1Tel").val(res.contact1Tel)
        //             $("#contact1Email").val(res.contact1Email)
        //             $("#creditCode").val(res.creditCode)
        //             $("#remark").val(res.remark)
        //             // 监听提交
        //             form.on('submit(demo1)', function (data) {
        //                 console.log(data);
        //                 $.ajax({
        //                     url: "/ChuBoWen/UpdateMdVendor",
        //                     type: "get",
        //                     async: true,
        //                     data: data.field,
        //                     contentType: "application/json",
        //                     success: res => {
        //                         console.log(res);
        //                         if (res.data == 1) {
        //                             var index = parent.layer.getFrameIndex(window.name); // 先得到当前 iframe 层的索引
        //                             parent.layer.close(index); // 再执行关闭
        //                         }
        //                         else if (res.data == 0) {
        //                             layer.msg("单位编码或名称已存在")
        //                         }
        //                         else {
        //                             layer.msg("修改失败")
        //                         }
        //                     }
        //                 });
        //             });
        //         }
        //     });
        // })
    </script>
</body>
</html>